<?php
function cpx_get_email_store($cp_ids, $st_id, $follow_id,$site_name = 'MostCoupon.com')
{
    include('header.php');
    include('body_head.php');
    include('body_foot.php');

    $st_name = get_post_field('post_title', $st_id);
    $email_header = "New $st_name coupons from $site_name";

    $email_head = return_email_head();
    $store_logo = get_post_meta($st_id, 'logo_metadata', true);
    $store_url = get_permalink($st_id);
    $body_head = return_body_head(site_url(), $email_header, $store_logo, $store_url);
    $body_foot = return_body_foot(site_url(),$follow_id);
    $link_view_all_cps = home_url("/?p=$st_id");

    $cp_detail = '';
    if(count($cp_ids) > 0)
    {
        foreach ($cp_ids as $id) {
            $outlink_cp = get_permalink($st_id).'/?c='.$id."&email=1";
            $cp_title = get_post_field('post_title', $id);
            $cp_des = get_post_field('post_content', $id);

            $cp_detail .= <<<EOD
            <table class="w580" width="580" cellpadding="0" cellspacing="0" border="0" style="margin-top: 10px;">
                                                   <tbody>
                                                      <tr>
                                                         <td class="w580" width="580">
                                                            <p align="left" class="article-title"
                                                            style = "font-size:18px";font-weight:bold
                                                            >
                                                                <a href="$outlink_cp" style="color:#A05A92;text-decoration:none">$cp_title</a>
                                                            </p>
                                                            <div align="left" class="article-content" style="color:#474747">
                                                               <multiline label="Description">$cp_des</multiline>
                                                            </div>
                                                            <a href="$outlink_cp" class="get-coupon"><div class="get-coupon" style="cursor:pointer">Get Coupon</div></a>
                                                         </td>
                                                      </tr>
                                                      <tr>
                                                         <td class="w580" width="580" height="10"></td>
                                                      </tr>
                                                   </tbody>
                                                </table>
                                                <hr />
EOD;

        }
        $cp_detail .= "<a href='$link_view_all_cps' title='View more coupons'>View more $st_name coupons</a>";
    }
    return $email_head.$body_head.$cp_detail.$body_foot;
}
?>